package com.onpositive.wiki3.db.catmodel.matches;

import com.onpositive.wiki3.db.catmodel.Category;
import com.onpositive.wiki3.db.catmodel.ICategoryMatcher;

public class DeapRemover implements ICategoryMatcher {

	String title;

	public DeapRemover(String string) {
		this.title = string.toLowerCase().replace(' ', '_');
	}

	@Override
	public int accept(Category st) {
		if (title.equals(this.title)) {
			doRe(st);
		}
		return 0;
	}

	protected void doRe(Category st) {
		st.remove();
		for (Category categories :st.getChildCategories()){
			if (categories.parentCount()==0){
				doRe( categories);
			}			
		}
	}
}
